﻿using AutoMapper;
using FutureApp.Shop.Dto;

namespace FutureApp.Shop.Mapper
{
    internal class GoodsProfile : Profile
    {
        public GoodsProfile()
        {
            this.CreateMap<Goods, GoodsEntityDto>()
                .ForMember(dest => dest.Price, opt => opt.MapFrom(src => src.Pricing.Price))
                .ForMember(dest => dest.SalePrice, opt => opt.MapFrom(src => src.Pricing.SalePrice))
                .ForMember(dest => dest.BottomPrice, opt => opt.MapFrom(src => src.Pricing.BottomPrice))
                .ForMember(dest => dest.Quantity, opt => opt.MapFrom(src => src.Stock.Quantity));
            this.CreateMap<CreateGoodsInput, GoodsItem>()
                .ForMember(dest => dest.GoodsList, opt => opt.MapFrom(src => src.SKUs));
            this.CreateMap<UpdateGoodsInput, GoodsItem>()
                .ForMember(dest => dest.GoodsList, opt => opt.Ignore());
        }
    }
}
